from khl import Message,Bot
from db.dbTools import LiteDb

def make_dice(bot:Bot,db:LiteDb):

    @bot.command(name="setDice",prefixes=["/","."])
    async def setDice(msg:Message,dice:int=0):
        if dice == 0:
            await msg.reply("骰子面数不能为0")
        else:
            d = db.db_setDice(msg.ctx.channel.id,dice)
            if d == 1:
                await msg.reply("修改成功")

    @bot.command(name="getDice",prefixes=["/","."])
    async def getDice(msg:Message):
        d = db.db_getDice(msg.ctx.channel.id)
        if d is not None:
            await msg.reply(f"当前频道的默认骰子点数为{d}")
        else:
            await msg.reply(f"当前频道未设置默认骰子")